package com.nju.crawler.config.source;


import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

@Configuration
public class DataSourceConfig {

    /**
     * 第一个数据连接，默认优先级最高
     * @return
     */
    @Primary
    @Bean("primaryDataSource")
    @ConfigurationProperties(prefix="spring.datasource")
    public DataSource PrimaryDataSource() {
        return DataSourceBuilder.create()
                .type(HikariDataSource.class).build();
    }

    // 拓展多数据源
}